package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IUnusualDailyFeedBackForInstallView;
import com.cloudsigns.factorymanager2.engineering.model.IUnusualFeedBackForInstallModel;
import com.cloudsigns.factorymanager2.engineering.model.UnusualFeedBackForInstallModel;

/**
 * Created by tony on 2018/4/14.
 */

public class UnusualFeedBackForInstallPrsenter {
    private IUnusualDailyFeedBackForInstallView view;
    private IUnusualFeedBackForInstallModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public UnusualFeedBackForInstallPrsenter(IUnusualDailyFeedBackForInstallView view) {
        this.view = view;
        this.model = new UnusualFeedBackForInstallModel();
    }

    public void submitUnusualFeedBackForInstall() {


        model.submitUnusualFeedBackForInstall(view.getAdvice(), view.getId(), view.getImgUrlList(), view.getItemId(), view.getType()
                , view.getUnusualDays(), view.getUnusualReason(), new UnusualFeedBackForInstallModel.OnUnusualFeedBackFroInstallListener() {
                    @Override
                    public void submitUnusualFeedBackForInstallSunccessed() {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.submitUnusualFeedBackForInstallViewSuccessed();
                                view.hideLoading();
                            }
                        });
                    }

                    @Override
                    public void submitUnusualFeedBackForInstallFailed(final String desc) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.submitUnusualFeedBackForInstallViewFailed(desc);
                                view.hideLoading();
                            }
                        });
                    }
                });

    }
}
